package com.example.myapplication.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

import com.example.myapplication.model.UserName;
import com.example.myapplication.LoginActivity;
import com.example.myapplication.R;


public class Mine extends Fragment implements View.OnClickListener{
    private RelativeLayout toLogin;
    private TextView toLoginText,title_Text;
    private String name;


    public Mine(String fName){
        this.name = fName;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_mine,container,false);
        title_Text = (TextView) view.findViewById(R.id.title_Text);
        toLoginText = (TextView) view.findViewById(R.id.mine_toLogin_text);

        String message = null;
        Bundle bundle =getArguments();//得到从Activity传来的数据
        if(bundle!=null){
            message = bundle.getString("data");
        }
        toLoginText.setText(UserName.name);


        title_Text.setText("主页");
        return view;
    }


    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        toLogin = (RelativeLayout) getActivity().findViewById(R.id.mine_toLogin);
        toLogin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.mine_toLogin:
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
                getActivity().finish();
                break;
        }
    }


}
